#ifndef LHC_ITEXTWRITER_H_INCLUDED_
#define LHC_ITEXTWRITER_H_INCLUDED_

#include "UnicodeString.h"
#include "Format.h"
#include "Environment.h"

namespace lhcutils
{

class ITextWriter
{
public:
	// Throws lhcutils::IoException on IO error.
	virtual void Write(const UnicodeString& str) = 0;
	void Write(const UnicodeString& formatString, const UnicodeString& arg1);
	void Write(const UnicodeString& formatString, const UnicodeString& arg1, const UnicodeString& arg2);
	void Write(const UnicodeString& formatString, const UnicodeString& arg1, const UnicodeString& arg2, const UnicodeString& arg3);
	void Write(const UnicodeString& formatString, const UnicodeString& arg1, const UnicodeString& arg2, const UnicodeString& arg3, const UnicodeString& arg4);

	template<class TInputIterator>
	void Write(const UnicodeString& formatString, TInputIterator begin, TInputIterator end)
	{
		StringPtr formatted = Format(formatString, begin, end);
		Write(formatted);
	}

	virtual void WriteLine(const UnicodeString& str);
	void WriteLine(const UnicodeString& formatString, const UnicodeString& arg1);
	void WriteLine(const UnicodeString& formatString, const UnicodeString& arg1, const UnicodeString& arg2);
	void WriteLine(const UnicodeString& formatString, const UnicodeString& arg1, const UnicodeString& arg2, const UnicodeString& arg3);
	void WriteLine(const UnicodeString& formatString, const UnicodeString& arg1, const UnicodeString& arg2, const UnicodeString& arg3, const UnicodeString& arg4);

	template<class TInputIterator>
	void WriteLine(const UnicodeString& formatString, TInputIterator begin, TInputIterator end)
	{
		StringPtr formatted = Format(formatString, begin, end);
		StringPtr formattedWithNewline = formatted + Environment::GetNewline();
		Write(formattedWithNewline):
	}

	virtual ~ITextWriter();
};

}

#endif

/*
 Copyright 2011 Greg Najda

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/
